#ifndef _HTTPRESPONSESTREAM_HPP_
#define _HTTPRESPONSESTREAM_HPP_

#include "jhdefs.hpp"
#include "stream/streambuf.hpp"
using JHCPP::stream::UnbufferedStreamBuf;
#include <istream>
#include <ostream>

NET_NAMESPACE_BEGIN


class CHTTPClientSession;
class CHTTPResponseStreamBuf : public UnbufferedStreamBuf
{
public:
	CHTTPResponseStreamBuf(std::istream& istr);
	~CHTTPResponseStreamBuf();

private:
	int readFromDevice();

	std::istream& m_istr;
};


class CHTTPResponseIOS : public virtual std::ios
{
public:
	CHTTPResponseIOS(std::istream& istr);
	~CHTTPResponseIOS();

	CHTTPResponseStreamBuf* rdbuf();

protected:
	CHTTPResponseStreamBuf m_buf;
};


class CHTTPResponseStream : public CHTTPResponseIOS, public std::istream
{
public:
	CHTTPResponseStream(std::istream& istr, CHTTPClientSession* pSession);
	~CHTTPResponseStream();

private:
	CHTTPClientSession* m_pSession;
};

NET_NAMESPACE_END

#endif
